package it.creazionicreative.engine;

import it.creazionicreative.Const;
import it.creazionicreative.Utils;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;

public class GPSEngine extends BaseEngine {

	private LocationManager locman;
	private LocationListener loclis;
	private Location loc = null;
	
	public Location getLocation() { return loc;};
	
	public GPSEngine(Activity activity) {
		super(activity, Const.ENGINE_GPS);
		
	}
	
	@Override
	public void Init() {
		locman = (LocationManager)getappActivity().getSystemService(Context.LOCATION_SERVICE);
		
		locman.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,0, new LocationListener() {
			
			public void onStatusChanged(String provider, int status, Bundle extras) {			
				
			}
			
			public void onProviderEnabled(String provider) {
				Utils.toast(getappActivity(), "GPS Enabled!");
			}
			
			public void onProviderDisabled(String provider) {
				Utils.toast(getappActivity(), "GPS Disabilited!");
			}
			
			public void onLocationChanged(Location location) {
				loc = location;
				Utils.toast(getappActivity(), String.format("LAT: %s LONG: %s", location.getLatitude(), location.getLongitude()));
			}
		});
		
		
		super.Init();
	}

}
